home *** CD-ROM | disk | FTP | other *** search
/ DOpus Plus / DOpus Plus.iso / Tutorial / C Guide / Simple_Module2 / includes / Window.h < prev   
C/C++ Source or Header  |  1998-08-26  |  3KB  |  134 lines

  1. /*******************************************************************
  2.  
  3.    Window.h
  4.     
  5.     Does open a DOpus window with an "Okay" and "Cancel" button,
  6.     a localized cycle gadget and a textgadget for doing some
  7.     output (it's getting later harder...).  
  8.     
  9. *********************************************************************/
  10. // our standard include, but we must think about later and so I do
  11. // simple trick...
  12.  
  13. #ifdef PARENT
  14. #include "/includes/Project.h"
  15. #else
  16. #include "includes/Project.h"
  17. #endif
  18.  
  19. // we need also some other defines from these -> 
  20. #include <libraries/gadtools.h>
  21. #include <intuition/gadgetclass.h>
  22.  
  23. // let's make again an useful define for us
  24. #define GET_ID(a)   (((struct Gadget *)(a->IAddress))->GadgetID)  
  25.  
  26. /********************************************************************/
  27. // now we have to declare what we want to have
  28. // we start with making some ID's
  29.  
  30. enum
  31. {
  32.     GADGET_ID_CYCLE,
  33.     GADGET_ID_TEXT,
  34.         
  35.     GADGET_ID_OKAY,
  36.     GADGET_ID_CANCEL 
  37. };
  38.  
  39. // Our cycle gadget should be localized and so we have to declare
  40. // an array with all ID's from our catalog description.
  41. // It must end with NULL !
  42.  
  43. USHORT labels[] = { { MSG_CLICK_ME }, { MSG_DO_AGAIN },
  44.                     { MSG_NICE_EHH }, NULL };  
  45.   
  46. // We must pass some Tags as well to our gadgets
  47. // here only for the cycle needed
  48.  
  49. struct TagItem cycle_tags[] =
  50. {
  51.     GTCustom_LocaleLabels, (ULONG) &labels[0],  // set our locale labels
  52.     TAG_DONE
  53. }; 
  54.     
  55. // Now we have to define the objects to be added to the window
  56.  
  57. ObjectDef odef[] =
  58. {
  59.     {
  60.         OD_GADGET, CYCLE_KIND, // what and what kind
  61.         { 1, 1, 10, 1 },       // char dimensions
  62.         { 0, 0, 20, 4 },       // "fine tuning"
  63.         MSG_CYCLE_GAD,         // title for the gadget (only an ID)
  64.         PLACETEXT_BELOW,       // flags
  65.         GADGET_ID_CYCLE,       // ID code for this gadget
  66.         &cycle_tags[0]         // pointer to additional tags
  67.     },
  68.     {
  69.         OD_GADGET, TEXT_KIND,
  70.         { 11, 1, SIZE_MAX_LESS-1, 1 },
  71.        { 20, 0, 0, 4 },
  72.        NULL,
  73.         NULL,
  74.         GADGET_ID_TEXT,
  75.         NULL
  76.     },
  77.     {
  78.         OD_GADGET, BUTTON_KIND,
  79.         { 1, POS_RIGHT_JUSTIFY-1, 8, 1 },
  80.        { 0, 0, 0, 4 },
  81.         MSG_OKAY,
  82.         PLACETEXT_IN | BUTTONFLAG_OKAY_BUTTON,
  83.         GADGET_ID_OKAY,
  84.         NULL
  85.     },
  86.     {
  87.         OD_GADGET, BUTTON_KIND,
  88.         { POS_RIGHT_JUSTIFY-1, POS_RIGHT_JUSTIFY-1, 8, 1 },
  89.        { 0, 0, 0, 4 },
  90.         MSG_CANCEL,
  91.         PLACETEXT_IN | BUTTONFLAG_CANCEL_BUTTON,
  92.         GADGET_ID_CANCEL,
  93.         NULL
  94.     },
  95.     { OD_END }
  96. };
  97.  
  98. // It's high time to define the window (means the size)
  99.  
  100. ConfigWindow cfgwin =
  101. {
  102.     { 
  103.         POS_CENTER, POS_CENTER, // center window (left and top)
  104.         40, 8                   // window size in char dimensions
  105.     },
  106.     {  0, 0, 0, 0 }            // we do here no "fine tuning"... 
  107. };        
  108.     
  109. /********************************************************************/            
  110. // now we define a structure, which makes our life easier
  111.  
  112. typedef struct _WindowHandle
  113. {
  114.     struct Screen       *screen;
  115.     struct Window       *win;
  116.     ObjectList          *olist;
  117.     struct IntuiMessage *imsg;
  118.     ULONG                signals;
  119.     
  120.     APTR                 notify_handle;
  121.     struct MsgPort      *notify_port;
  122.     DOpusNotify         *notify_msg;
  123.     
  124.     FuncArgs            *fargs;
  125.     char                 buffer[32];
  126.     ULONG                result;
  127.     
  128. }  WindowHandle; 
  129.  
  130. /********************************************************************/
  131. // prototype for our function, which may be exported
  132.  
  133. void OwnWindow( STRPTR args, struct Screen *screen );
  134.